﻿<Window x:Class="TeacherLoad.Windows.SpecList"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TeacherLoad.Windows"
        mc:Ignorable="d"
        Title="Специальности" 
        Height="500" Width="900"
        MinHeight="500" MinWidth="900"
        WindowStartupLocation="CenterScreen"
        Background="#BFF7E9">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="320"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>

        <GroupBox x:Name="HeaderSpecAdd"
                    Header="Новая специальность"
                  BorderBrush="#200772">
            <StackPanel>
                <Label Content="Код специальности"/>
                <TextBox x:Name="txCode"
                         TextChanged="text_TextChanged"/>
                <Label Content="Наименование специальности"/>
                <TextBox x:Name="txNameSpec"
                         TextChanged="text_TextChanged"
                         Height="70"
                         TextWrapping="Wrap"
                         VerticalScrollBarVisibility="Auto"/>
                <Label Content="Квалификация"/>
                <TextBox x:Name="txQualification"
                         TextChanged="text_TextChanged"
                         Height="70"
                         TextWrapping="Wrap"
                         VerticalScrollBarVisibility="Auto"/>
                <Button x:Name="btnAddSpec"
                        Content="Добавить специальность"
                        Click="btnAddSpec_Click"/>
                <Button x:Name="btnCancelEdit"
                        Content="Отменить редактирование"
                        Visibility="Collapsed"
                        Click="btnCancelEdit_Click"/>
                <Button x:Name="btnClearText"
                        Content="Очистить поле ввода"
                        Visibility="Collapsed"
                        Click="btnClearText_Click"/>
            </StackPanel>
        </GroupBox>
        
        <GroupBox Grid.Column="1"
                  Header="Список специальностей">
            <Grid>
                <ListBox x:Name="listSpec"
                         ItemsSource="{Binding}"
                         SelectionChanged="listSpec_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <TextBlock Text="{Binding Path=Code}"
                                           Margin="0,0,10,0"/>
                                <TextBlock Text="{Binding Path=NameSpec}"
                                           Grid.Column="1"/>
                                <TextBlock Text="{Binding Path=Qual_str}"
                                           Grid.Row="1"
                                           Grid.Column="1"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem x:Name="ChangeRow"
                                Header="Изменить специальность"
                                      Click="ChangeRow_Click"/>
                        </ContextMenu>
                    </ListBox.ContextMenu>
                </ListBox>
            </Grid>
        </GroupBox>
        <StatusBar Grid.Row="1" Grid.ColumnSpan="2"
                   Background="#BFF7E9">
            <StatusBarItem>
                <TextBlock Text="{Binding StringFormat=Количество записей: {0},
                    ElementName=listSpec, Path=Items.Count}"
                           Margin="5 0"/>
            </StatusBarItem>
        </StatusBar>

    </Grid>
</Window>
